{extend name="public:base"}
{block name='css'}
<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
{/block}
{block name="js"}

<script type="text/javascript">
    function delAll(self){
        if ($(self).hasClass('ed')) {
            return false;
        }

        layer.confirm('真的要删除吗？删除后将无法找回！', {
            btn: ['确定','取消'] //按钮
        }, function(){
            myRequestRefresh(self, "{:url('delAll')}", $("#delRecord").serialize());
        }, function(){

        });
    }

    function del(self, id){
        if ($(self).hasClass('ed')) {
            return false;
        }

        layer.confirm('真的要删除吗？删除后将无法找回！', {
            btn: ['确定','取消'] //按钮
        }, function(){
            myRequestRefresh(self, "{:url('del')}", {id:id});
        }, function(){

        });
    }

    $(function(){
        //全选的实现
        $(".check-all").click(function(){
            $(".ids").prop("checked", this.checked);
        });
        $(".ids").click(function(){
            var option = $(".ids");
            option.each(function(i){
                if(!this.checked){
                    $(".check-all").prop("checked", false);
                    return false;
                }else{
                    $(".check-all").prop("checked", true);
                }
            });
        });

    });

</script>
{/block}
{block name='body'}
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>通知管理</h5>
                        <a href="{:url('save')}" class="btn btn-sm btn-primary pull-right m-t-n-xs">添加通知</a>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <form name="form" action="{:url('index')}" method="get">
                                <div class="col-sm-1 m-b-xs">
                                    <input type="submit" class="btn btn-sm btn-primary btn-sm btn-danger pull-left" onclick="delAll(this);return false;" value="删除"  />
                                </div>

                                <div class="col-sm-4 m-b-xs">
                                    <div class="input-group">
                                        <input type="text" name="keywords" placeholder="标题" value="{:input('keywords', '', 'trim')}" class="input-sm form-control"> <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <form name="form" action=""  method="post" id="delRecord">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th>
                                        <input class="check-all" type="checkbox" value="">
                                    </th>
                                    <th>标题</th>
                                    <th>内容</th>
                                    <th>添加时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach name="list" item="li"}
                                <tr>
                                    <td><input type="checkbox" class="ids" value="{$li.id}" name="id[]"></td>
                                    <td>{$li.title|default='-'}</td>
                                    <td>{$li.content|default=''}</td>
                                    <td>{$li.add_time|date="Y-m-d H:i:s",###}</td>
                                    <td>
                                        <a href="{:url('save', ['id'=>$li['id']])}" class="btn btn-success btn-xs edit"><i class="fa fa-edit"></i> 编辑</a>
                                        <a href="javascript:;" onclick="del(this, {$li.id});" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> 删除</a>
                                    </td>
                                </tr>
                                {/foreach}
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="20">
                                        <div class="zy_page">{$list->render()}</div>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        
    </div>
    
</body>
{/block}
